using UnityEditor;
using UnityEditor.Rendering;
using UnityEngine;

namespace CNGraphi.U6URP.Editor
{
    /// <summary>
    /// 程序化平面云材质检视板
    /// <para>作者：CN.Graphi</para>
    /// </summary>
    public class ProceduralCloudGUI : ShaderGraphGUI
    {
        bool bNoise = true;
        bool bVertexAni = true;
        bool bSurfaceColor = true;
        bool bSoftFade = true;

        protected override void DrawCustomSurfaceInput(Material material) 
        {
            DrawFoldout(ref bNoise, "Noise", () => 
            {
                ShowProperty("_NoiseProjection", "Projection");

                DrawVector2Property("_BaseNoiseSpeed", "Base Speed");
                ShowProperty("_BaseNoiseScale", "Base Scale");
                ShowProperty("_BaseNoiseIntensity", "Base Intensity");
                EditorGUILayout.Space(15);

                DrawVector2Property("_NoiseSpeed", "Speed");
                ShowProperty("_NoiseScale", "Scale");
                ShowProperty("_NoisePower", "Power");
                EditorGUILayout.Space(15);
                ShowProperty("_NoiseRemap", "Remapping");
                ShowProperty("_NoiseEdge1", "Smooth Step Min");
                ShowProperty("_NoiseEdge2", "Smooth Step Max");
            });

            EditorGUILayout.Space(10);
            DrawFoldout(ref bVertexAni, "Vertex", () =>
            {
                ShowProperty("_NoiseHeight", "Amplitude");
                ShowProperty("_BOWL_CROOKED", "Bowl crooked");
                if(FindProp("_BOWL_CROOKED").floatValue == 1)
                {
                    materialEditor.MinFloatShaderProperty(FindProp("_Radius"), new GUIContent(""), 0);
                }
            });


            EditorGUILayout.Space(10);
            DrawFoldout(ref bSurfaceColor, "Surface Color", () =>
            {
                ShowProperty("_ColorPeak", "Peak Color");
                ShowProperty("_ColorValley", "Valley Color");
                EditorGUILayout.Space(10);
                ShowProperty("_FrenselPower", "Fresnel Power");
                ShowProperty("_FrenselIntensity", "Fresnel Intensity");
                EditorGUILayout.Space(10);
                ShowProperty("_EmissionIntensity", "Emission Intensity");
                EditorGUILayout.Space(10);
                ShowProperty("_Metallic");
                ShowProperty("_Smoothing");
            });


            EditorGUILayout.Space(10);
            DrawFoldout(ref bSoftFade, "Soft Fade", () =>
            {
                ShowProperty("_DepthFade", "Factor");
            });

        }
    }

}